﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Graph
{
    /// <summary>
    /// Represents a node of a graph
    /// </summary>
    /// <typeparam name="T">The type of object contained in the node</typeparam>
    
    public class GraphNode<T> : Node<T>
    {
        #region Properties

        private List<int> costs; //maps the weight to adjacent nodes

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a graph node with no data or neighbors - set the data/neighbors via the accessors
        /// </summary>
        
        public GraphNode()
            : base()
        {
        }
        
        /// <summary>
        /// Initializes a graph node with no neighbors - set the neighbors via the accessors
        /// </summary>
        /// <param name="value">The value of the node</param>
        
        public GraphNode(T value)
            : base(value)
        {
        }

        /// <summary>
        /// Initializes a graph node
        /// </summary>
        /// <param name="value">The value of the node</param>
        /// <param name="neighbors">The neighbors of the node</param>
        
        public GraphNode(T value, NodeList<T> neighbors)
            : base(value, neighbors)
        {
        }

        #endregion

        #region Accessors

        /// <summary>
        /// Gets the neighbors of the node - if the node has no neighbors, a neighbor list is created
        /// </summary>
        
        new public NodeList<T> Neighbors
        {
            get
            {
                if (base.Neighbors == null)
                {
                    {
                        base.Neighbors = new NodeList<T>();
                    }
                }
                return base.Neighbors;
            }

        }

        /// <summary>
        /// Gets the cost (the weight to neighbors) of the node - if the node has no costs list, the list is created
        /// </summary>
        
        public List<int> Cost
        {
            get
            {
                if (costs == null)
                {
                    costs = new List<int>();
                }
                return costs;
            }
        }

        #endregion
    }
}
